import json


class Request:
    """ Custom http Request """

    def getJson(func: object) -> object:
        """ Get JSON data in the request """

        def inner(view, request, *args, **kwargs):
            try:
                json_str = request.body
                json_dict = json.loads(json_str)
            except:
                json_dict = {}
            request.JSON = json_dict
            return func(view, request, *args, **kwargs)

        return inner
